}
z<-z+1
}
boxplot(beta[min:temp1],horizontal=TRUE,show.names = TRUE,main=main)
min<-min+temp
}
i<-i+1
}
is.numeric(beta)
dim(beta)
is.numeric(beta[,2:2662)
is.numeric(beta[,2:2662])
beta[,2:2662]<-as.numeric(as.character(beta[,2:2662]))
summary(beta[,192])
summary(beta[,191])
beta<-read.table("merged_beta1.txt",sep="\t",head=T)
beta<-read.table("merged_beta.txt",sep="\t",head=T)
beta<-read.table("merged_beta.txt",sep="\t",head=T,na.strings=c('-'),as.is=T)
beta<-read.table("merged_beta.txt",sep="\t",head=T,na.strings=c('-'),colClasses=colClasses)
summary(beta[,192])
dev.off()
pdf("test_boxplot.pdf")
i<-1
while(i<=length(names))
{
min<-min(which(site==names(table(site))[1]))+1
max<-max(which(site==names(table(site))[1]))+1
main<-names[i]
print(main)
while(min<max)
{
print(paste("min",min,sep=" "))
print(paste("max",max,sep=" "))
temp<-50
if(min+50 > max)
{
temp<-max-min
}
temp1<-min+temp
boxplot(beta[min:temp1],horizontal=TRUE,show.names = TRUE,main=main)
min<-min+temp
}
i<-i+1
}
dev.off()
pdf("test_boxplot.pdf")
i<-1
while(i<=length(names))
{
min<-min(which(site==names(table(site))[1]))+1
max<-max(which(site==names(table(site))[1]))+1
main<-names[i]
print(main)
while(min<max)
{
print(paste("min",min,sep=" "))
print(paste("max",max,sep=" "))
temp<-50
if(min+50 > max)
{
temp<-max-min
}
temp1<-min+temp
boxplot(beta[min:temp1],horizontal=FALSE,show.names = FALSE,main=main,xlab="SAMPLES",ylab="Beta")
min<-min+temp
}
i<-i+1
}
dev.off()
colnames(beta)[1:5]
dim(beta)
colnames(beta)<-c("SEGID",seq(1,2661))
pdf("test_boxplot.pdf")
i<-1
while(i<=length(names))
{
min<-min(which(site==names(table(site))[1]))+1
max<-max(which(site==names(table(site))[1]))+1
main<-names[i]
print(main)
while(min<max)
{
print(paste("min",min,sep=" "))
print(paste("max",max,sep=" "))
temp<-50
if(min+50 > max)
{
temp<-max-min
}
temp1<-min+temp
boxplot(beta[min:temp1],horizontal=FALSE,show.names = TRUE,main=main,xlab="SAMPLES",ylab="Beta")
min<-min+temp
}
i<-i+1
}
dev.off()
pdf("test_boxplot.pdf")
i<-1
while(i<=length(names))
{
min<-min(which(site==names(table(site))[i]))+1
max<-max(which(site==names(table(site))[i]))+1
main<-names[i]
print(main)
while(min<max)
{
print(paste("min",min,sep=" "))
print(paste("max",max,sep=" "))
temp<-50
if(min+50 > max)
{
temp<-max-min
}
temp1<-min+temp
boxplot(beta[min:temp1],horizontal=FALSE,show.names = TRUE,main=main,xlab="SAMPLES",ylab="Beta",ylim=c(0,1))
min<-min+temp
}
i<-i+1
}
dev.off()
table(site)
colnames(beta)<-c("SEGID",seq(1,2661))
sitenames<-c("BREAST","COLON","GLIOBLASTOMA","KIDNEY RENAL CLEAR","KIDNEY RENAL PAPILLARY","BLOOD LEUKEMIA","LUNG ADENOMA","LUNG SQUAMOUS","OVARY","RECTUM","STOMACH","UTERUS")
pdf("test_boxplot.pdf")
i<-1
while(i<=length(names))
{
min<-min(which(site==names(table(site))[i]))+1
max<-max(which(site==names(table(site))[i]))+1
main<-sitenames[i]
print(main)
while(min<max)
{
print(paste("min",min,sep=" "))
print(paste("max",max,sep=" "))
temp<-50
if(min+50 > max)
{
temp<-max-min
}
temp1<-min+temp
boxplot(beta[min:temp1],horizontal=FALSE,show.names = TRUE,main=main,xlab="SAMPLES",ylab="Beta",ylim=c(0,1))
min<-min+temp
}
i<-i+1
}
dev.off()
save.history("test_boxplot.R")
savehistory("test_boxplot.R")
savehistory("test_boxplot.R",max.show=T)
savehistory("test_boxplot.R",max.show)
savehistory("test_boxplot.R",max.show=1000)
save.history(pattern="read")
savehistory(pattern="read")
ls()
samples[1]
unlist(strsplit(samples[1], "\\."))
unlist(strsplit(samples[1], "\\."))[1]
unlist(strsplit(samples[1], "\\."))[5]
iqr(sample[1])
IQR(beta[,2])
summary(beta[,2])
iqr<-apply(beta[,2-],2,IQR)
iqr<-apply(beta[,2:],2,IQR)
iqr<-apply(beta[,2:2662],2,IQR)
IQR(beta[,192])
IQR(beta[,191])
IQR(beta[,192],na.rm=TRUE)
iqr=c()
i<-2
while(i<=2662)
{
iqr[i]<-IQR(beta[,192],na.rm=TRUE)
i<-i+1
}
length(iqr)
i<-2
iqr=c()
while(i<=2662)
{
iqr[i]<-IQR(beta[,i],na.rm=TRUE)
i<-i+1}
length(iqr)
iqr<-iqr[2:2662]
length(iqr)
iqr[1]
iqr[1:5]
summary(iqr)
beta[1,1:3]
iqr=c()
i<-1
n1<-ncol(beta)
n2<-nrow(beta)
while(i<=n2)
{
iqr[i]<-IQR(beta[i,2:n1],na.rm=TRUE)
i<-i+1
}
iqr<-apply(beta[,2:ncol(beta)],1,function(x)IQR(x,na.rm=TRUE))
length(iqr)
dim(beta)
summary(iqr)
length(which(iqr> 0.65))
length(which(iqr> 0.60))
length(which(iqr> 0.55))
length(which(iqr> 0.40))
length(which(iqr> 0.35))
length(which(iqr> 0.45))
length(which(iqr> 0.42))
length(which(iqr> 0.43))
pdf("heatmap.pdf")
heatmap(beta[which(iqr> 0.60),2:ncol(beta)])
data<-as.data.frame(beta[which(iqr> 0.60),2:ncol(beta)],is.numeric=T)
dim(data)
data<-as.data.frame(beta[which(iqr> 0.425),2:ncol(beta)],is.numeric=T)
dim(data)
heatmap(data)
data[1,1:40]
data<-as.data.frame(beta[which(iqr> 0.425),2:ncol(beta)],is.numeric=T,na.rm=T)
heatmap(data)
heatmap(as.numeric(data))
data<-as.numeric(as.character(data))
dim(data)
is.numeric(beta[,2:10])
is.factor(beta[,2:10])
is.character(beta[,2:10])
data<-as.matrix(beta[which(iqr> 0.425),2:ncol(beta)])
dim(data)
data[1,1:5]
heatmap(data)
dev.off()
pdf("heatmap.pdf")
heatmap(data)
dev.off()
colnames(data)[1]
colnames(data)[2]
dim(data)
unlist(strsplit(samples[1], "."))
ls()
unlist(strsplit(samples[1], "\\."))
length(site)
site[1,]
site[1]
length(names)
i<-1
while(i<2662)
{
site<-c()
i<-1
while(i<2662)
{
site[i]<- unlist(strsplit(samples[i], "\\."))
length(samples)
while(i<2662)
{
site[i]<- unlist(strsplit(samples[i], "\\."))[1]
i<-i+1
}
table(site)
i<-1
dis<-c()
while(i<2662)
{
dis<-unlist(strsplit(samples[i], "\\."))[5]
i<-i+1
}
table(dis)
i<-1
dis<-c()
while(i<2662)
{
dis[i]<-unlist(strsplit(samples[i], "\\."))[5]
i<-i+1}
table(dis)
dis1<-dis
dis1<-replace(01A,which(dis==01A),5)
dis1<-replace(c("01A"),which(dis==01A),5)
dis1<-replace(c("01A"),which(dis=="01A"),5)
table(dis1)
 dis1<-dis
dis1<-replace(c("01A","01B","01C","01D","01R","02A","03A","06A","11A","11B","20A"),seq(1,2661),c("1","2","3","4","5","6","7","8","9","10","11"))
dis[which(dis=="01A")]<-"1"
table(dis)
dis<-c()
i<-1
while(i<2662)
{
dis[i]<- unlist(strsplit(samples[i], "\\."))[1]
i<-i+1
}
table(dis)
dis<-c()
i<-1
while(i<2662)
{
dis[i]<- unlist(strsplit(samples[i], "\\."))[5]
i<-i+1
}
table(dis)
dis[1]
if(dis[1] == "01A"){print(1)}
i<-1
if(i==1||i==2){print(3)}
i<-2
if(i==1||i==2){print(3)}
i<-3
if(i==1||i==2){print(3)}
dis1<-c()
i<-1
while(i<2662)
{
if(dis[i] == "11A" || dis[i] == "11B")
{
dis1[i]<-2
}
else if(is[i] == "20A")
{
dis1[i]<-3
}
else
{
dis1[i]<-1
}
}
length(dis)
dis1<-c()
i<-1
while(i<2662)
{
if(dis[i] == "11A" || dis[i] == "11B")
{
dis1[i]<-2
}
else if(dis[i] == "20A")
{
dis1[i]<-3
}
else
{
dis1[i]<-1
}
}
dis1<-c()
i<-1
while(i<2662)
{
if(dis[i] == "11A" || dis[i] == "11B")
{
dis1[i]<-2
}
else if(dis[i] == "20A")
{
dis1[i]<-3
}
else
{
dis1[i]<-1
}
i<-i+1
}
length(site)
site[1]
table(site)
which(site=="BRCA")[1]
site[which(site=="BRCA")]<-"1"
site[which(site=="COAD")]<-"2"
site[which(site=="GBM")]<-"3"
site[which(site=="KIRC")]<-"4"
site[which(site=="KIRP")]<-"5"
site[which(site=="LAML")]<-"6"
site[which(site=="LUAD")]<-"7"
site[which(site=="LUSC")]<-"8"
site[which(site=="OV")]<-"9"
site[which(site=="READ")]<-"10"
site[which(site=="STAD")]<-"11"
site[which(site=="UCEC")]<-"12"
table(site)
table(dis1)
color.matrix<-rbind(site,dis1)
color.matrix<-as.matrix(rbind(site,dis1))
table(color.matrix[2,])
ls()
colnames(color.matrix)<-samples
rownames(color.matrix)<-c("TISSUE","COND")
dim(data)
colnames(data)<-samples
rownames(data)<-beta[which(iqr> 0.425),1]
spearman<-rcorr(data,type="spearman")
library("heatmap.plus")
spearman<-rcorr(data,type="spearman")
library(Hmisc)
spearman<-rcorr(data,type="spearman")
clab<-matrix(as.character(t(color.matrix)),nrow=dim(color.matrix)[2],ncol=dim(color.matrix)[1])
pdf("heatmap.pdf")
heatmap(data,ColSideColors=clab,RowSideColors=NA)
dev.off()
dim(clab)
library(Hmisc)
library("gplots")
library(gplots)
spearman<-rcorr(data,type="spearman")
hc<-hclust(as.dist(1-spearman$r),"ave")
pdf("heatmap.pdf")
heatmap.plus(spearman$r,ColSideColors=clab,RowSideColors=clab,cexRow=0.5,cexCol=0.5,scale="none",Colv=as.dendrogram(hc),col=greenred(256),Rowv=as.dendrogram(hc),main="With Clustering")
heatmap.plus(spearman$r,ColSideColors=clab,RowSideColors=clab,cexRow=0.5,cexCol=0.5,scale="none",Colv=as.dendrogram(hc),Rowv=as.dendrogram(hc),main="With Clustering")
dev.off()
pdf("heatmap.pdf")
rownames(clab)
table(clab[1,])
table(clab[2,])
clab
table(clab[,1])
table(clab[,2])
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=clab[,1],RowSideColors=NA)
heatmap(data,ColSideColors=clab[,1])
dev.off()
pdf("heatmap_noclust.pdf")
heatmap(data,ColSideColors=clab[,1],hclustfun = NA)
dev.off()
pdf("heatmap_noclust.pdf")
heatmap(data,ColSideColors=clab[,1],dendogram = NA)
dev.off()
pdf("heatmap_noclust.pdf")
heatmap(data,ColSideColors=clab[,1],Colv=NA)
dev.off()
table(clab[,1])
colors<-as.vector(clab[,1])
which(colors==1)
colors[which(colors==1)]<-"black"
colors[which(colors==1)]<-"red"
colors[which(colors==1)]<-""
colors<-as.vector(clab[,1])
site<-c()
i<-1
while(i<2662)
{
site[i]<- unlist(strsplit(samples[i], "\\."))[1]
i<-i+1
}
table(site)
site[which(site=="BRCA")]<-"black"
site[which(site=="COAD")]<-"red"
site[which(site=="GBM")]<-"green"
site[which(site=="KIRC")]<-"blue"
site[which(site=="KIRP")]<-"cyan"
site[which(site=="LAML")]<-"magenta"
site[which(site=="LUAD")]<-"yellow"
site[which(site=="LUSC")]<-"gray"
site[which(site=="OV")]<-"violet"
site[which(site=="READ")]<-"orange"
site[which(site=="STAD")]<-"white"
site[which(site=="UCEC")]<-"darkblue"
pdf("heatmap_noclust.pdf")
heatmap(data,ColSideColors=site,Colv=NA)
dev.off
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,main="Beta accross tissues")
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST")
legend("top",title="Tissue",fill=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
getwd()
setwd("/data2/bsi/RandD/bora/METHYLATION/")
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,main="BETA ACROSS TISSUES",xlab=c("SAMPLES"),ylab=c("HIGH IQR 500 PROBES"),)
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("PROBES"))
legend("top",title="Tissue",fill=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
pdf("heatmap.pdf")
dim(data)
heatmap(data,ColSideColors=site,main="BETA ACROSS TISSUES",xlab=c("SAMPLES"),ylab=c("HIGH IQR 525 PROBES"),labRow=NA,labCol=NA)
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("top",title="Tissue",fill=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("topleft",title="Tissue",fill=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("topright",cex=0.2,title="Tissue",fill=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
pdf("heatmap.pdf")
dev.off()
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("topright",cex=0.2,title="Tissue",fill=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("topright",cex=0.2,title="Tissue",col=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
pdf("heatmap.pdf")
legend("topright",cex=0.2,title="Tissue",col=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("topright",cex=0.2,title="Tissue",fil=site,col=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
pdf("heatmap.pdf")
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("topright",cex=0.5,title="Tissue",fil=site,col=site,c("BRCA","COAD","GBM","KIRC","KIRP","LAML","LUAD","LUSC","OV","READ","STAD","UCEC"))
dev.off()
pdf("heatmap1.pdf")
heatmap(data,ColSideColors=site,main="BETA ACCROSS TISSUES",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("topright",cex=0.4,title="Tissue",fil=c("black","red","green","blue","cyan","magenta","yellow","gray","violet","orange","white","darkblue"),c("BREAST","COLON","GLIOBLASTOMA","KIDNEY RENAL CLEAR","KIDNEY RENAL PAPILLARY","BLOOD LEUKEMIA","LUNG ADENOMA","LUNG SQUAMOUS","OVARY","RECTUM","STOMACH","UTERUS"))
heatmap(data,ColSideColors=site,Colv=NA,main="BETA ACCROSS TISSUES NO COL CLUST",xlab=c("SAMPLES"),ylab=c("TOP IQR 525 PROBES"),labRow=NA,labCol=NA)
legend("topright",cex=0.4,title="Tissue",fil=c("black","red","green","blue","cyan","magenta","yellow","gray","violet","orange","white","darkblue"),c("BREAST","COLON","GLIOBLASTOMA","KIDNEY RENAL CLEAR","KIDNEY RENAL PAPILLARY","BLOOD LEUKEMIA","LUNG ADENOMA","LUNG SQUAMOUS","OVARY","RECTUM","STOMACH","UTERUS"))
dev.off()
